package com.suprema.biomini;

import com.technofovea.hllib.JnaEnum;

/**
 *  錯誤接受率(False Accept Rate)等級-指的把錯誤的指紋誤判為真的機率.
 * @author Kent Yeh
 */
public enum SecurityLevel implements JnaEnum<SecurityLevel> {

    /**
     * 錯誤接受率低於 1%
     */
    FAR1,
    /**
     * 錯誤接受率低於 0.1%
     */
    FAR2,
    /**
     * 錯誤接受率低於 0.01%
     */
    FAR3,
    /**
     * (預設)錯誤接受率低於 0.001%
     */
    FAR4,
    /**
     * 錯誤接受率低於 0.0001%
     */
    FAR5,
    /**
     * 錯誤接受率低於 0.00001%
     */
    FAR6,
    /**
     * 錯誤接受率低於 0.000001%
     */
    FAR7;
    private static int start = 0;

    public SecurityLevel getForValue(int i) {
        for (SecurityLevel o : this.values()) {
            if (o.getIntValue() == i) {
                return o;
            }
        }
        return null;
    }

    public int getIntValue() {
        return this.ordinal() + start;
    }

    @Override
    public String toString() {
        switch (this.ordinal()) {
            case 2:
                return "<0.1%";
            case 3:
                return "<0.01%";
            case 4:
                return "<0.001%";
            case 5:
                return "<0.0001%";
            case 6:
                return "<0.00001%";
            default:
                return "<1%";
        }
    }

    public String toLogString() {
        switch (this.ordinal()) {
            case 2:
                return "錯誤接受率低於 0.1%";
            case 3:
                return "錯誤接受率低於 0.01%";
            case 4:
                return "錯誤接受率低於 0.001%";
            case 5:
                return "錯誤接受率低於 0.0001%";
            case 6:
                return "錯誤接受率低於 0.00001%";
            default:
                return "錯誤接受率低於 1%";
        }
    }
}
